#include "Logger.h"
#include <Windows.h>
#include <cstdarg>
#include <stdio.h>

void Logger::Debug(const char* format, ...)
{
	char szBuffer[1024];
	char szB2[1024];
	SYSTEMTIME st;

	va_list pArgList;
	va_start(pArgList, format);
	vsnprintf(szBuffer, sizeof(szBuffer), format, pArgList);
	va_end(pArgList);

	GetLocalTime(&st);

	sprintf(szB2, "%02d:%02d:%02d.%03d [%d] debug: %s\n",
		// current time
		st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
		// process id
		GetCurrentProcessId(),
		// debug log
		szBuffer);

	OutputDebugString(szB2);
	printf("%s", szB2);
}

void Logger::Error(const char* format, ...)
{
	char szBuffer[1024];
	char szB2[1024];
	SYSTEMTIME st;

	va_list pArgList;
	va_start(pArgList, format);
	vsnprintf(szBuffer, sizeof(szBuffer), format, pArgList);
	va_end(pArgList);

	GetLocalTime(&st);

	sprintf(szB2, "%02d:%02d:%02d.%03d [%d] error: %s\n",
		// current time
		st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
		// process id
		GetCurrentProcessId(),
		// debug log
		szBuffer);

	OutputDebugString(szB2);
	printf("%s", szB2);
}

void Logger::Info(const char* format, ...)
{
	char szBuffer[1024] = {0};
	char szB2[1024] = {0};
	SYSTEMTIME st;

	va_list pArgList;
	va_start(pArgList, format);
	vsnprintf(szBuffer, sizeof(szBuffer), format, pArgList);
	va_end(pArgList);

	GetLocalTime(&st);

	sprintf(szB2, "%02d:%02d:%02d.%03d [%d] info: %s\n",
		// current time
		st.wHour, st.wMinute, st.wSecond, st.wMilliseconds,
		// process id
		GetCurrentProcessId(),
		// debug log
		szBuffer);

	OutputDebugString(szB2);
	printf("%s", szB2);
}
